<link href="../../../css/common.css" rel="stylesheet" type="text/css" />
<style>
    input,select{
        height: 26px;
    }
    .button-control{
        height: 50px;
    }
    .button-control a{
        display: inline-block;
        float: left;
        margin: 2px 0 0 5px;
        width: 70px;
    }
    .btn-rep{
        border: 1px solid #ccc;
        border-radius: 4px;
        background: #DFDFDF;
    }
    .btn-rep:hover,.rep-selected{
        background: #428BCA;
        color: #fff;
    }
    .select-person{
        width: 150px;
        height: 32px;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        color: #555;
        background-color: #fff;
        background-image: none;
        border: 1px solid #ccc;
        border-radius: 4px;
        -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
        -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
        -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        vertical-align: middle;
    }
    .radio-rep{vertical-align: middle;}
</style>
<h3 style = "display: inline-block;"><B>问题管理</B></h3>

<a class="btn btn-secondary" href="/#/question/add" style = "margin: -5px 0 0 20px;padding: 5px 8px;border-radius: 4px;">小6发帖</a>
<a class="btn btn-secondary" href="/#/600post" style = "margin: -5px 0 0 20px;padding: 5px 8px;border-radius: 4px;">小号发帖</a>

<br><br>
<form class="form-inline">
    <div class="form-group">
        <p id="errorMsg" class="text-danger" ng-show="showErrorForQueryCondition==true"></p>
        <label class="control-label" for="textinput">小区:</label>
        <!--<select ng-model="communityId" ng-options="m.objId as m.communityName for m in communityLabelList.data">-->
            <!--&lt;!&ndash;ng-change="selectCondition(communityId,category,description)">&ndash;&gt;-->
            <!--<option value="">&#45;&#45; 请选择 &#45;&#45;</option>-->
        <!--</select>-->
        <input type = "text" id = "community_select" value = "">


        <label class="control-label" for="textinput">分类:</label>
        <select ng-model="category" ng-options="c.value as c.name for c in categoryList">
            <!--ng-change="selectCondition(communityId,category,description)">-->
            <option value="">全部</option>
        </select>
        <label class="control-label" for="textinput">标签:</label>
        <select ng-model="tagflg">
            <option value="all">全部</option>
            <option value="yes">有标签</option>
            <option value="no">无标签</option>
        </select>
        <label class="control-label" for="textinput">回复:</label>
        <select ng-model="replieflg">
            <!--<option value="? object:null ?"></option>-->
            <option value="all">全部</option>
            <option value="yes">有</option>
            <option value="no">无</option>
        </select>
        <label class="control-label" for="textinput">精华帖:</label>
        <select ng-model="level">
            <!--<option value="? object:null ?"></option>-->
            <option value="all">全部</option>
            <option value="yes">精华帖</option>
            <option value="no">非精华帖</option>
        </select>

        <!-- 按发布、按回复 排序-->
        <label class="control-label" for="textinput">排序方式:</label>
        <select ng-model="sortType" ng-change="selectSortType()" id = "sort_select">
            <option value="release">发布</option>
            <option value="reply">回复</option>
        </select>


        <!--<label class="control-label" for="textinput">零回复:</label>-->
        <!--<div class="checkbox">-->
        <!--<label>-->
        <!--<input type="checkbox" class="form-control" ng-model="replieflg" >-->
        <!--</label>-->
        <!--</div>-->
        <br><br>
        <label class="control-label" for="textinput">发布时间:</label>
        <input type="text" id="startDate" class="form-control datepicker" size="12" data-date-format="yyyy-mm-dd">
        <label class="control-label" for="textinput">至：</label>
        <input type="text" id="endDate" class="form-control datepicker" size="12" data-date-format="yyyy-mm-dd">

        <label class="control-label" for="textinput">创建者:</label>
        <input type="text" class="form-control" placeholder="" style="margin-left:0px;width: 100px" ng-model="nickname">

        <label class="control-label" for="textinput">创建者ID:</label>
        <input type="text" class="form-control" placeholder="" style="margin-left:0px;width: 150px" ng-model="userId">

        <label class="control-label" for="textinput">关键字:</label>
        <input type="text" class="form-control" placeholder="" style="margin-left:0px;width: 150px"
               ng-model="description">

        <!--<input type="text" class="form-control" placeholder="用户id" style="margin-left: 20px;width: 200px" required-->
        <!--ng-model="userId">-->
        <!--<button type="submit" class="btn btn-default" ng-click="searchUserQuestion(userId)">搜索</button>-->

        <button type="submit" id="btnSearch" class="form-control btn btn-secondary"
                ng-click="selectCondition(communityId,category,tagflg,replieflg,nickname,description,level,userId)">搜索
        </button>
        <button type="submit" class="btn btn-default" ng-click="exportQuestionList()">导出</button>

    </div>
</form>
<br>
<paging>
    <ul class="pagination" num-pages="tasks.pageCount" current-page="tasks.currentPage"
        on-select-page="selectPage(page)">
        <li ng-class="{disabled: noPrevious()}"><a ng-click="selectPrevious()">&laquo;</a>

        </li>
        <li ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a
                ng-click="selectPage(page)">{{page}}</a>

        </li>
        <li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">&raquo;</a>

        </li>
        <li ng-show="currentPage>6"><a ng-click="selectPage(1)">首页</a>

        </li>
    </ul>
</paging>

<div class="tab-content" style="margin-top: 20px">
    <div class="tab-pane active" id="tab_b">
        <table class="table table-condensed" id = "tab_list">
            <thead>
            <tr>

                <th>所属小区<!--community--></th>
                <th>板块内小区<!--otherCommunity--></th>
                <!--<th>小号&lt;!&ndash;numbers&ndash;&gt;</th>-->
                <th>标签<!--status--></th>
                <th>浏览次数<!--browserCount--></th>
                <th>点赞数量<!--praiseCount--></th>
                <th>描述<!--desc--></th>
                <th>回复/数量</th>
                <th>创建者<!--createdBy--></th>
                <th>发布时间<!--createdBy--></th>
                <th>最后修改时间<!--dateLastModified--></th>
                <th>分类</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="question in recommendList">

                <td><div style = "width: 90px;line-height: 1.2;">{{question.community.communityName}}</div></td>
                <td><div style = "width: 70px;line-height: 1.2;"><div style = "display: table-cell;vertical-align: middle;"><span ng-repeat="t in question.aroundCommunity">{{t}} </span></div></div></td>
                <td><div class = "ell" style = "display: table;width: 40px;white-space:normal;line-height: 1.2;"><div style = "display: table-cell;vertical-align: middle;"><span ng-repeat="t in question.tag">{{t}} </span></div></div></td>
                <td><div style = "width: 30px;word-break:break-all;line-height: 1.2;">{{question.browserCount}}</div></td>
                <td><div style = "width: 30px;word-break:break-all;line-height: 1.2;">{{question.praiseCount}}</div></td>
                <td style="width: 400px;word-wrap:break-word;"><div style = "position: relative;width: 400px;line-height: 1.2;">{{question.desc}}</div></td><!--onmouseover="hideContent(this)"-->
                <td>
                    <div class = "ell" style = "width: 70px;line-height: 1.2;"><a href="javascript:void(0)" data-toggle="modal" data-target="#resModal{{$index}}">查看</a>/
                    {{question.replies.length}}
                    <div class="modal fade" id="resModal{{$index}}" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content" style = "overflow-y: scroll;height: 600px;">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-label="Close"><span
                                            aria-hidden="true">&times;</span></button>
                                    <h5 class="modal-title" id="myModalLabel" style = "white-space:normal; width:930px;">问题：{{question.desc}}</h5>
                                </div>
                                <div class="modal-body">
                                    <slide ng-repeat="img in question.images" active="img.active">
                                        <img ng-src="{{img.imageURL}}" style="width: 180px;height: 180px;">
                                    </slide>
                                </div>
                                <div class="modal-body">
                                    <table class="table table-condensed">
                                        <thead>
                                        <tr>
                                            <th>回复</th>
                                            <th>回复者</th>
                                            <th>小区</th>
                                            <th align="right">回复时间</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr ng-repeat="r in question.replies" data-rep-id={{r.repliedBy.objId}} data-rep-name={{r.repliedBy.nickName}} ng-click="getRepId($event)">

                                            <td width="200" style = "white-space:normal; width:700px;">{{r.replyDesc}}</td>
                                            <td width="100">{{r.repliedBy.nickName}}</td>
                                            <td width="100">{{r.repliedBy.communityName}}</td>
                                            <td width="150">{{r.dateReplied | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                                            <!--<td><button type="button" class="btn btn-secondary btn-sm" ng-click="reviseReply(question,data,data2)">编辑</button></td>-->

                                        </tr>
                                        </tbody>
                                    </table>
                                    <form>
                                    <div style = "margin-bottom: 10px;">
                                        <label style = "margin-right: 42px;" ng-click="repPost($event)"><input type="radio" checked="true" name="repClass" value="post" class="rep-post radio-rep"> 回复帖子</label>
                                        <label style = "margin-right: 6px;" ng-click="repPerson($event)"><input type="radio" name="repClass" value="person" class="rep-person radio-rep"> 回复某人</label><input type = "text" readonly placeholder="点击每行选择" class = "select-person" ng-model="data2.repName">
                                    </div>
                                    <div style = "margin-bottom: 10px;">
                                        <label ng-click="accountMain($event)"><input type="radio" checked="true" name="repPerson" value = "main" class = "radio-rep"> 小6客服</label>
                                        <label style="margin-left: 50px;" ng-click="accountSmall($event)"><input type="radio" name="repPerson" value = "small" class = "radio-rep"> 其他</label> <input type = "text" placeholder="请输入小号" class = "select-person" style = "margin-left: 6px;" ng-model="data2.smallId">
                                    </div>
                                    <input type="text" class="form-control" placeholder="回复内容..."
                                           ng-model="data.replies.replyDesc" id="reply">
                                    </form>
                                </div>

                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary btn-sm" ng-click="sendReply(question,data,data2,$event)" data-community-id = {{question.community.objId}}>回复
                                    </button>
                                    <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">关闭
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div></div>
                </td>
                <td><div style = "width: 70px;line-height: 1.2;">{{question.createdBy.nickName}}</div></td>
                <td><div class = "ell" style = "width: 100px;line-height: 24px;">{{question.dateCreated | date:'yyyy-MM-dd'}}<br>{{question.dateCreated | date:'HH:mm:ss'}}</div></td>
                <td><div class = "ell" style = "width: 100px;line-height: 24px;">{{question.dateLastModified | date:'yyyy-MM-dd'}}<br>{{question.dateLastModified | date:'HH:mm:ss'}}</div></td>
                <td>
                    <select ng-model="question.category" ng-options="c.value as c.name for c in categoryList"
                            ng-change="changeCategory(question.objId,question.category)">
                        <option value="">-- 请选择 --</option>
                    </select>
                </td>
                <td width="350">
                    <div style = "margin: 0;padding: 0;width: 160px;line-height: 20px;" class = "button-control">
                        <a class="btn btn-default btn-xs" ng-click="gotoQuestionEditPage(question.objId)">编辑</a>
                        <span ng-if="category !=null">
                          <a class="btn btn-primary btn-xs" ng-show="question.categoryOrder==null" ng-click="moveToTop(question)">置顶</a>
                          <a class="btn btn-danger btn-xs" ng-show="question.categoryOrder!=null" ng-click="cancelTop(question)">取消</a>
                        </span>
                        <!--<span ng-if="category ==null">-->
                          <!--<a class="btn btn-primary btn-xs" ng-show="question.allOrder==null" ng-click="moveToTop(question)">置顶</a>-->
                          <!--<a class="btn btn-danger btn-xs" ng-show="question.allOrder!=null" ng-click="cancelTop(question)">取消</a>-->
                        <!--</span>-->

                       <a class="btn btn-secondary btn-xs" ng-click="deleteQuestion(question)">删除</a>
                       <!--<a class="btn btn-primary btn-xs" ng-show="question.isFresh !=true" data-toggle="modal" data-target="#fresh{{$index}}" ng-click="">添加新鲜事</a>-->

                    <div class="modal fade" id="fresh{{$index}}" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel" aria-hidden="false">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-label="Close"><span
                                            aria-hidden="true">&times;</span></button>
                                    <h5 class="modal-title" id="myFresh">问题：{{question.desc}}</h5>
                                </div>
                                <div class="modal-body">
                                    <h6 class="modal-title" id="myFresh1">请输入标题：</h6>
                                    <textarea rows="5" ng-model="title" required style="width:100%"
                                              tabindex="7"></textarea>
                                </div>
                                <div class="modal-footer">
                                    <button ng-click="addToFreshNews(question,title)" type="button"
                                            class="btn btn-default btn-sm" data-dismiss="modal">确定
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!--<a ng-show="question.isFresh == true" class="btn btn-secondary btn-xs">已在新鲜事</a>-->

                    <a ng-show="question.level !=1" class="btn btn-secondary btn-xs"
                       ng-click="changeLevel(question,1)">设置精华贴</a>
                    <a ng-show="question.level ==1" class="btn btn-danger btn-xs"
                       ng-click="changeLevel(question,0)">取消精华贴</a>

                        <span ng-show="question.tag!=null&&question.tag.length>0"> <a class="btn btn-secondary btn-xs"
                                                                                      ng-click="pushQuestion(question)">标签推送</a>
                            </span>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<paging>
    <ul class="pagination" num-pages="tasks.pageCount" current-page="tasks.currentPage"
        on-select-page="selectPage(page)">
        <li ng-class="{disabled: noPrevious()}"><a ng-click="selectPrevious()">&laquo;</a>

        </li>
        <li ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a
                ng-click="selectPage(page)">{{page}}</a>

        </li>
        <li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">&raquo;</a>

        </li>
        <li ng-show="currentPage>6"><a ng-click="selectPage(1)">首页</a>

        </li>
    </ul>
</paging>

<div class="modal fade" id="pushModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">推送内容：</h4>
            </div>
            <div class="modal-body">
                <p>
                <ul>
                    <li>问题： {{pushMessage.question.desc}}</li>
                    <li>标签： <span ng-repeat="t in pushMessage.question.tag">{{t}} </span></li>
                    <li>创建者： {{pushMessage.question.createdBy.nickName}}</li>
                    <li>预计发送人数：{{pushMessage.uList.length}}</li>
                </ul>

                </p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="confirmPush()">发送</button>

            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="userQuestion">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">问答列表：</h4>
            </div>
            <div class="modal-body">
                <table class="table table-condensed">
                    <thead>
                    <tr>
                        <th>类型</th>
                        <th>问题</th>
                        <th>回复</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="quesiton in userQuestionList">

                        <td width="50"><span ng-show="quesiton.isCreated ==true">提问</span>
                            <span ng-show="quesiton.isCreated ==false">回复</span>
                        </td>
                        <td>{{quesiton.desc}}</td>
                        <td>{{quesiton.myReply}}</td>

                    </tr>
                    </tbody>
                </table>
            </div>

            <div class="modal-footer">
                <button type="button"
                        class="btn btn-default btn-sm" data-dismiss="modal">关闭
                </button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<div class="modal fade" id="delteQuestion">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">是否删除?</h4>
        </div>
        <div class="modal-body">
            <textarea rows="3" required style="width:100%" placeholder="删除原因..." ng-model="delRemark">
            </textarea>
        </div>
        <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="confirmdelete()">确认</button>
            </div>
        </div>
    </div>
</div>

<div class = "display-hide-content" id = "display_hide_content" onmouseout = "this.style.display = 'none'"><div id = "display_hide_content1"></div><div id = "display_hide_close">关闭</div></div>

<script>


    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
                (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                            ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }

    var fromDate = $('#startDate').datepicker().on('changeDate', function (ev) {
        //alert(ev.date.format('yyyy-MM-dd'));
        //$scope.startDate=ev.date.format('yyyy-MM-dd');
        $("#startDate").val(ev.date.format('yyyy-MM-dd'));
//        alert(ev.date);
    });

    var toDate = $('#endDate').datepicker().on('changeDate', function (ev) {
        // alert(ev.date.format('yyyy-MM-dd'));
        //$scope.endDate=ev.date.format('yyyy-MM-dd');
        $("#endDate").val(ev.date.format('yyyy-MM-dd'));
    });

    var hideContent = function(obj){
        $("#display_hide_content").css("display","block");
        $("#display_hide_content1").text(obj.innerText);
        $("#display_hide_content")[0].style.left = obj.offsetLeft + "px";
        $("#display_hide_content")[0].style.top = 60 + obj.offsetTop + "px";
    };

    $("#display_hide_close").on("click",function(){
        $("#display_hide_content").css("display","none");
    });

</script>   